#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;
    vector<int> arr(n+1);
    for(int i=1; i<=n; i++)    cin >> arr[i];

    vector<long long> dp(n+1);
    for(int j=1; j<=n; j++)
    {
        dp[j] = dp[j-1] + arr[j];
    }

    int l, r;
    while(q--)
    {
        cin >> l >> r;
        cout << dp[r] - dp[l-1] << endl;
    }

    return 0;
}
